import CountUI from '../../views/Count/index_优化前'
import {connect} from 'react-redux'
import {createAddAction, createMinusAction,  createAddActionAsync} from '../../redux/actions/count'
// mapStateToProps函数返回的对象中的key作为UI组件的props的key，value作为props的value —— 状态
function mapStateToProps(state) {
  return {count: state}
}
// mapDispatchToProps函数返回的对象中的key作为UI组件的props的key，value作为props的value —— 操作状态的方法
function mapDispatchToProps(dispatch) {
  return {
    // 通知redux执行加法
    add: value => dispatch(createAddAction(value)),
    minus: value => dispatch(createMinusAction(value)),
    addAsync: (value, delay) => dispatch(createAddActionAsync(value, delay))
  }
}
// 生成一个容器组件
const CountContainer = connect(mapStateToProps, mapDispatchToProps)(CountUI)
export default CountContainer